#include <bits/stdc++.h>
using namespace std;
void Print_Matrix_in_Circle(int** numbers,int cols,int rows,int start)
{
    int endX = cols-1-start,endY = rows-1-start;
    for(int i=start;i<=endX;++i)
    {
        int number = numbers[start][i];
        cout<<number<<" ";
    }
    if(start<endY)
    {
        for(int i = start+1;i<endY;++i)
        {
            int number = numbers[i][endX];
            cout<<number;
        }
    }
    if(start<endX&&start<endY)
    {
        for(int i=endX-1;i>=start;--i)
        {
            int number = numbers[endY][i];
            cout<<number;
        }
    }
    if(start<endX&&start<endY-1)
    {
        for(int i = endY-1;i>=start+1;--i)
        {
            int number = numbers[i][start];
            cout<<number;
        }
    }
}
void Print_Matrix(int** number,int cols,int rows)
{
    if(number == nullptr||cols<=0||rows<=0)
        return;
    int start = 0;
    while(cols>start*2&&rows>start*2)
    {
        Print_Matrix_in_Circle(number,cols,rows,start);
        ++start;
    }
}
int main()
{
    int a1[] = {1,2,3,4};
    int a2[] = {5,6,7,8};
    int a3[] = {9,10,11,12};
    int a4[] = {13,14,15,16};
    int *a[4] = {a1,a2,a3,a4};
//    int a[4][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
    Print_Matrix(a,4,4);

}